package StudyCode.summary.csv;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReturnsStringArrayCSVValueSpecifiedDelimiter {

	public static void main(String[] args) {
		String str = "www.tah1986.com";
		System.out.println("分割前: " + str);
		System.out.println(".号分割后: " + Arrays.toString(splitSeparatedValues(str, ".")));
	}

	public static String[] splitSeparatedValues(String csvString,
	                                            String delim) {
		StringTokenizer st = new StringTokenizer(csvString, delim);
		List<String> list = new ArrayList<String>(st.countTokens());

		while (st.hasMoreTokens()) {
			list.add(st.nextToken());
		}

		String[] values = (String[]) list.toArray(new String[list.size()]);
		return values;
	}
}
